const option = {
  menuPosition: 'right',
  submitBtn: false,
  emptyBtn: false,
  column: [
    {
      label: '仓库',
      prop: 'warehouseId',
      filterable: true,
      multiple: false,
      disabled: false,
      type: 'select',
      dicUrl: '/api/mes-warehouse/warehouse/page?size=5000&current=1',
      props: {
        label: 'name',
        value: 'id'
      },
      dicFormatter: (data) => {
        return data.data.records || [];
      },
      span: 6
    },
    {
      label: '物料编码',
      prop: 'partNo',
      filterable: true,
      disabled: false,
      span: 6
    },
    // {
    //   label: '供应商',
    //   prop: 'partnerName',
    //   span: 6
    // },
    {
      label: '',
      prop: 'btn',
      span: 6,
      formslot: true
    }
  ]
};

const tableOption = {
  border: true,
  addBtn: false,
  viewBtn: false,
  editBtn: false,
  delBtn: false,
  index: true,
  menu: true,
  columnBtn: false,
  refreshBtn: false,
  showSummary: true,
  indexLabel: '序号',
  column: [
    {
      label: '物料编码',
      prop: 'partNo',
      span: 7
    },
    {
      label: '物料名称',
      prop: 'partName'
    },
    {
      label: '物料规格',
      prop: 'partSpec'
    },
    // {
    //   label: '供应商',
    //   prop: 'partnerName'
    // },
    {
      label: '数量',
      prop: 'quantity'
    },
    {
      label: '金额',
      prop: 'price'
    },
    {
      label: '最长在库时间(天)',
      prop: 'duration'
    }
  ]
};

export const trendTableOption = {
  border: true,
  addBtn: false,
  viewBtn: false,
  editBtn: false,
  delBtn: false,
  menu: false,
  columnBtn: false,
  refreshBtn: false,
  column: [
    {
      label: '表头',
      prop: 'statisticalMonth',
      headerslot: true
    },
    {
      label: '0-30天',
      prop: 'price0To30',
      span: 7
    },
    {
      label: '31-90天',
      prop: 'price31To90'
    },
    {
      label: '91-180天',
      prop: 'price91To180'
    },
    {
      label: '181-365天',
      prop: 'price181To365'
    },
    {
      label: ' 365天以上',
      prop: 'priceAbove365'
    },
    {
      label: '合计（元）',
      prop: 'priceTotal'
    },
    {
      label: '环比',
      prop: 'priceRate',
      html: true,
      formatter: (val) => {
        if (val.priceRate) {
          if (val.priceRate.includes('-')) {
            return '<b style="color:#00aa00">' + val.priceRate * 100 + '%' + '</b>';
          } else {
            return '<b style="color:red">' + val.priceRate * 100 + '%' + '</b>';
          }
        }
      }
    }
  ]
};
const detailTableOption = {
  border: true,
  addBtn: false,
  viewBtn: false,
  editBtn: false,
  delBtn: false,
  index: true,
  menu: false,
  columnBtn: false,
  refreshBtn: false,
  indexLabel: '序号',
  column: [
    {
      label: '物料品牌',
      prop: 'partBrand'
    },
    {
      label: '物料型号',
      prop: 'partModel'
    },
    {
      label: '物料批次',
      prop: 'lotNo'
    },
    {
      label: '数量',
      prop: 'quantity'
    },
    {
      label: '入库日期',
      prop: 'inboundTime'
    },
    {
      label: '在库时间（天）',
      prop: 'duration'
    }
  ]
};
const peiOption = {
  title: {
    text: '库存金额占比',
    left: 'center',
    textStyle: {
      fontSize: 18,
      fontWeight: 'bold',
      color: '#333'
    }
  },
  tooltip: {
    trigger: 'item'
  },
  legend: {
    bottom: '5%',
    left: 'center'
  },
  series: [
    {
      name: '金额',
      type: 'pie',
      radius: '50%',
      data: [
      ],
      label: {
        show: true,
        position: 'outside',
        formatter: '{b}: {d}%'
      },
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      },
    }
  ]
};

const barOption = {
  title: {
    text: '库龄分布图',
    left: 'center',
    textStyle: {
      fontSize: 18,
      fontWeight: 'bold',
      color: '#333'
    }
  },
  tooltip: {
    trigger: 'item', // 触发方式为项目（柱状图）
    formatter: '点击柱状图可显示对应库龄的详细物料数据' // 提示内容格式
  },
  legend: {
    bottom: '5%',
    left: 'center',
    data: ['数量', '金额']
  },
  xAxis: {
    type: 'category',
    data: ['0-30天', '31-90天', '91-180天', '181-365天', '365天以上']
  },
  yAxis: [
    {
      type: 'value',
      name: '数量'
    },
    {
      type: 'value',
      name: '金额'
    }
  ],

  series: [
    {
      name: '数量',
      data: [],
      type: 'bar',
      itemStyle: {
        color: '#4874cb' // 设置柱子的颜色
      },
      label: {
        show: true,
        position: 'top',
        formatter: function (params) {
          return params.value; // 显示 Y 值
        }
      }
    },
    {
      name: '金额',
      data: [],
      type: 'bar',
      itemStyle: {
        color: '#ee822f' // 设置柱子的颜色
      },
      label: {
        show: true,
        position: 'top',
        formatter: function (params) {
          return params.value; // 显示 Y 值
        }
      },
      yAxisIndex: 1
    }
  ]
};
const lineOption = {
  title: {
    text: '库龄金额分布趋势',
    textStyle: {
      fontSize: 18,
      fontWeight: 'bold',
      color: '#333'
    },
    left: 'center'
  },
  tooltip: {
    trigger: 'axis'
  },
  legend: {
    data: ['0-30天', '31-90天', '91-180天', '181-365天', '365天以上'],
    right: '5%',
    bottom: '15%',
    orient: 'vertical'
  },
  grid: {
    left: '3%',
    right: '15%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: []
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      name: '0-30天',
      type: 'line',
      stack: 'Total',
      data: []
    },
    {
      name: '31-90天',
      type: 'line',
      stack: 'Total',
      data: []
    },
    {
      name: '91-180天',
      type: 'line',
      stack: 'Total',
      data: []
    },
    {
      name: '181-365天',
      type: 'line',
      stack: 'Total',
      data: []
    },
    {
      name: '365天以上',
      type: 'line',
      stack: 'Total',
      data: []
    }
  ]
};
export { option, tableOption, peiOption, barOption, lineOption, detailTableOption };
